import { Agent } from '../entities/agent';
import { AgentDto } from '../dtos';
import { DeepPartial } from 'typeorm';

export function entityToDto(agent: Agent): AgentDto {
  return {
    id: agent?.id,
    identity: agent?.identity,
    desc: agent?.desc,
    advertiseIp: agent?.advertise_ip,
    port: agent?.port,
    products: agent?.products,
    status: agent?.status,
    role: agent?.role,
    password: agent?.password,
    cpu: agent?.cpu,
    drive: agent?.drive,
    memory: agent?.memory,
    disconnectedAt: agent?.disconnected_at
  };
}

export function dtoToEntity(dto: AgentDto): DeepPartial<Agent> {
  return {
    id: dto?.id,
    identity: dto?.identity,
    desc: dto?.desc,
    advertise_ip: dto?.advertiseIp,
    port: dto?.port,
    products: dto?.products,
    status: dto?.status,
    role: dto?.role,
    password: dto?.password,
    cpu: dto?.cpu,
    drive: dto?.drive,
    memory: dto?.memory,
    disconnected_at: dto?.disconnectedAt
  };
}